<template>
  <div style="display: flex;">
    <!-- 左侧菜单栏 -->
    <div :style="{width:(isCollapse ? '64px' : '208px')}">
      <el-menu
          background-color="#3CB371"
          style="width:100%;height:100vh;overflow: scroll"
          text-color="#fff"
          active-text-color="#ff0"
          :collapse="isCollapse"
          unique-opened
          router
          :collapse-transition="false"
      >
        <!-- 菜单的顶部条 -->
        <el-row style="padding-top: 10px;">
          <el-col :span="2"></el-col>
          <el-col :span="7" style="padding-left: 7px;">
            <el-avatar src="/imgs/admin/logo.jpg" style="width: 35px;height: 35px;"></el-avatar>
          </el-col>
          <el-col :span="isCollapse ? 0 : 13">
            <span style="color:#fff;font-weight:bold;position:relative;top:8px;left:2px;">课程预约后台</span>
          </el-col>
        </el-row>
        <el-sub-menu index="1">
          <template #title>
            <el-icon style="font-size: 21px;"><User/></el-icon><span>学员管理</span>
          </template>
          <el-menu-item index="/account">账号管理</el-menu-item>
          <el-menu-item index="/student">学员列表</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="2">
          <template #title>
            <el-icon style="font-size: 21px;"><Postcard/></el-icon><span>课程卡管理</span>
          </template>
        </el-sub-menu>
        <el-sub-menu index="3">
          <template #title>
            <el-icon style="font-size: 21px;"><Ticket/></el-icon><span>排课配置</span>
          </template>
          <el-menu-item index="/geofence">新增排课</el-menu-item>
          <el-menu-item index="/geofence">考勤</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="4">
          <template #title>
            <el-icon style="font-size: 21px;"><House/></el-icon><span>商城管理</span>
          </template>
          <el-menu-item index="/application">商城分类</el-menu-item>
          <el-menu-item index="/audit">商品列表</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="5">
          <template #title>
            <el-icon style="font-size: 21px;"><ShoppingCart/></el-icon><span>订单管理</span>
          </template>
          <el-menu-item index="/application">订单列表</el-menu-item>
          <el-menu-item index="/application">订单详情</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="6">
          <template #title>
            <el-icon style="font-size: 21px;"><Histogram/></el-icon><span>数据统计</span>
          </template>
          <el-menu-item index="/application">购卡记录</el-menu-item>
          <el-menu-item index="/application">消费记录</el-menu-item>
          <el-menu-item index="/application">老师消课</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="7">
          <template #title>
            <el-icon style="font-size: 21px;"><MessageBox/></el-icon><span>基础信息管理</span>
          </template>
          <el-menu-item index="/dict">学校管理</el-menu-item>
          <el-menu-item index="/dict">教室管理</el-menu-item>
          <el-menu-item index="/dict">班级管理</el-menu-item>
          <el-menu-item index="/dict">科目管理</el-menu-item>
          <el-menu-item index="/dict">员工管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="8">
          <template #title>
            <el-icon style="font-size: 21px;"><Tools/></el-icon><span>系统设置</span>
          </template>
          <el-menu-item index="/dict">字典列表</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </div>
    <!-- 右侧顶部条与主体内容(可变区域) -->
    <div :style="{width:(isCollapse ? 'calc(100% - 64px)' : 'calc(100% - 208px)')}">
      <!-- 右侧顶部条 -->
      <el-header style="height:10vh;background-color:#fff;padding-top: 22px;">
        <el-row :gutter="10">
          <!-- 折叠图标按钮  -->
          <el-col :span="18">
            <el-icon style="font-size:20px;" @click="changeCollapse"><Expand/></el-icon>
          </el-col>
          <!-- 登录人姓名与退出登录  -->
          <el-col :span="6" style="position: relative;">
            <el-dropdown trigger="click" style="position: absolute;right: 20px;">
              <span style="font-size:19px;font-weight: bold;">
<!--                {{user.username}}-->
                <el-icon><arrow-down/></el-icon>
              </span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </el-col>
        </el-row>
        <!-- 面包屑导航  -->
        <el-breadcrumb separator="/" style="position: relative;top: 20px;">
          <el-breadcrumb-item>首页</el-breadcrumb-item>
          <el-breadcrumb-item >{{item}}</el-breadcrumb-item>
        </el-breadcrumb>
      </el-header>
      <!-- 右侧主体内容(可变区域) -->
      <el-main style="height:90vh;padding: 0;overflow-y: auto;">
        <router-view/>
      </el-main>
    </div>
  </div>
</template>

<script setup>
//定义变量用来控制左侧菜单栏是否折叠
import {ref} from "vue";

const isCollapse = ref(false);
const changeCollapse = ()=>{
  if (isCollapse.value){
    isCollapse.value=false
  }else{
    isCollapse.value=true
  }
}
</script>
